﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcDemo.FilterTest
{
    public class TestAuthorizeAttribute:AuthorizeAttribute
    {
        /// <summary>
        /// 授权过滤器 --在Action过滤器前执行
        /// </summary>
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            filterContext.HttpContext.Response.Write("你还没有登录<br/><a href='/FilterTest/Login'>登录</a>");
            filterContext.HttpContext.Response.End();
            //注释掉父类方法，因为父类里的 OnAuthorization 方法会调用asp.net的授权验证机制！
            //base.OnAuthorization(filterContext);
        }
    }
}